-
Notifications
You must be signed in to change notification settings - Fork 8.2k
cmake: linker: dont place device tree memories at absolute addresses #86464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: linker: dont place device tree memories at absolute addresses #86464
Conversation
Avoid placing the device tree memories at an absolute address. This avoids placing both .rom_start AND SSRAM1 at the same address on mps2/an521/cpu0. This seems fine according to ld (since one placement is empty) but causes a currently non-suppressable diag_warning Signed-off-by: Robin Kastberg <[email protected]>
The reason for this is when devicetree defines memory regions, for example like zephyr/boards/arm/mps3/mps3_corstone300_an547.dts Lines 76 to 80 in 95c1c85
then the linker generator should create a corresponding memory region and section. and there the address of 0x30000000 should of course correspond to the address defined in devicetree. By using the memory region node from devicetree we remove the requirement that the user must duplicate this information in CMake. |
I see how this could be a problem to some linkers, and is probably not noticed until now because as you mention then ld has no problems with such colliding addresses. I looked a bit at the ld generator, and it seems the ld generator is actually using the value from the memory region ( |
This was something like I expected. But I still don't see anyone using the actual sections.. And this usage is not easy to search for. |
That could be because not all code placement has been updated. And the creation of memory regions and sections based on devicetree was added here: #43603 The ld-templates still creates the same memory regions and sections as we should be doing in the CMake linker:
zephyr/include/zephyr/arch/arm/cortex_m/scripts/linker.ld Lines 406 to 407 in 4bb5ffd
@carlocaione do you have any additional input regarding this topic ? |
|
yup, matching the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting discussion but have we actually uncovered anything stopping this change?
ah right, this doesn't change the creation of the memory regions, only adjustment of the output section.
Guess I got myself a bit side-tracked when explaining the devicetree to linker memory creation 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We will try IAR on Renesas boards soon.
Ah good! We have a known issue that CMAKE_LINKER_GENERATOR is not in sync with LD skeleton for renesas boards (option bytes). e.g. for ek_ra4e2 |
|
@RobinKastberg , it seems now is the right time to try IAR :) |
In CMAKE_LINKER_GENERATOR linker scripts, avoid placing the device tree memories at an absolute address. This avoids placing both
.rom_startANDSSRAM1at the same address onmps2/an521/cpu0.This seems fine according to ld (since one placement is empty) but causes a currently non-suppressable error in IAR linker.
I am a bit unclear about the reason for this construction.
Is it to be able to do attribute(section("SSRAM1")) after having configured the device tree, then that is very handy. But doesn't really require specific ADDRESS.
Or are there use cases I am not thinking about here?